<?php

/**
 * 作者：lucas
 * 链接：
 * 邮箱：dissipator_520@qq.com
 */

/**
 * A3 Model
 *
 * @author lucas
 */
class A3Model extends Model {

    public function orderbillq(){

          $Where="  where year(date1)>=(year(getdate())-1) and s_whouse in ('301','302')";
          $Query="SELECT year(date1) as sname,month(date1) as xname,sum(qty) as data from  orderbill" .$Where;
          $Query  .= " group by year(date1),month(date1) order by year(date1),month(date1)";
          $results=$this->a3sql($Query);
          // p($results);
          if ($results)return $results; 
    }

    public function orderbillv(){


          $Where="  where year(date1)>=(year(getdate())-1) and s_whouse in ('301','302')";
          $Query="SELECT year(date1) as stack,month(date1) as xname,descript as sname,right(sum(value),20)as data from  orderbill" .$Where;
          $Query  .= " group by year(date1),month(date1),descript order by year(date1),month(date1),descript;";
          $results=$this->a3sql($Query);
          // p($results);
          if ($results)return $results; 

    }

    function a3sql($Query){
      
      $link = mssql_connect('192.168.0.201\\NG','luoml','000');
      // echo 111;
      // die();
      $results=array();
      if ($link) {
          mssql_select_db("NG0001",$link);
          // echo $Query;die;
          $result = mssql_query($Query);
          if ($result){
           while($row=mssql_fetch_array($result))
              {     
                  $results[]=$row;
              }
          }
          // p($results);die;
          if ($results)return $results; 
      }
       else return fasle;
       mssql_close($link);
    }  

}


?>
